package com.dsl.tms.mapper.tmsdb;

import com.dsl.tms.entity.tmsdb.QuartzEntity;
import org.apache.ibatis.annotations.*;

import java.util.ArrayList;

@Mapper
public interface QuartzMapper {

    @Select(" SELECT job.job_name,job.job_group,job.description,job.job_class_name," +
            " cron.cron_expression,tri.trigger_name,tri.trigger_state" +
            " FROM qrtz_job_details job,qrtz_triggers tri,qrtz_cron_triggers cron" +
            " WHERE job.job_name = tri.job_name AND cron.trigger_name = tri.trigger_name" +
            " AND tri.trigger_type='CRON'")
    @Results({
            @Result(column = "job_name",property = "jobName"),
            @Result(column = "job_group",property = "jobGroup"),
            @Result(column = "description",property = "description"),
            @Result(column = "job_class_name",property = "jobClassName"),
            @Result(column = "cron_expression",property = "cronExpression"),
            @Result(column = "trigger_name",property = "triggerName"),
            @Result(column = "trigger_state",property = "triggerState")
    })
    public ArrayList<QuartzEntity> queryAllCronQuartz();

    @Select(" SELECT job.job_name,job.job_group,job.description,job.job_class_name," +
            " cron.cron_expression,tri.trigger_name,tri.trigger_state" +
            " FROM qrtz_job_details job,qrtz_triggers tri,qrtz_cron_triggers cron" +
            " WHERE job.job_name = tri.job_name AND cron.trigger_name = tri.trigger_name" +
            " AND tri.trigger_type='CRON' AND job.job_name=#{quartz.jobName}")
    @Results({
            @Result(column = "job_name",property = "jobName"),
            @Result(column = "job_group",property = "jobGroup"),
            @Result(column = "description",property = "description"),
            @Result(column = "job_class_name",property = "jobClassName"),
            @Result(column = "cron_expression",property = "cronExpression"),
            @Result(column = "trigger_name",property = "triggerName"),
            @Result(column = "trigger_state",property = "triggerState")
    })
    public QuartzEntity queryCronQuartz(@Param("quartz") QuartzEntity quartzEntity);


}
